package com.codeoss.framework.view.renderer.store;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.renderer.IComponentRenderer;

@Service
public class ComponentRendererStore implements IComponentRendererStore,ApplicationContextAware {
	private ApplicationContext applicationContext;
	@Override
	public IComponentRenderer getComponentRenderer(YunContext yunContext,Component component) {
		// TODO Auto-generated method stub
		String type=component.getType();
		IComponentRenderer	componentRenderer=(IComponentRenderer)applicationContext.getBean(type+"Renderer");
		return componentRenderer;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		// TODO Auto-generated method stub
		this.applicationContext=applicationContext;
	}

}
